﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="NewsInformation.cs" company="DissingNelleman">
//   
// All rights reserved. </copyright>
// <summary>
//   The news information.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace ServiceLibrary.Models.Domain
{
    using System;
    using System.Collections.Generic;

    using NHibernate.Mapping.ByCode.Conformist;

    using ServiceLibrary.Models.Base;

    /// <summary>
    /// The news information.
    /// </summary>
    public class NewsInformation : Entity
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="NewsInformation"/> class.
        /// </summary>
        public NewsInformation()
        {
            this.Files = new HashSet<File>();
            this.Funds = new HashSet<Fund>();
            this.OwnerProjects = new HashSet<Project>();
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the archive location.
        /// </summary>
        public virtual string ArchiveLocation { get; set; }

        /// <summary>
        /// Gets or sets the comments.
        /// </summary>
        public virtual string Comments { get; set; }

        /// <summary>
        /// Gets or sets the creator.
        /// </summary>
        public virtual User Creator { get; set; }

        /// <summary>
        /// Gets or sets the files.
        /// </summary>
        public virtual ICollection<File> Files { get; set; }

        /// <summary>
        /// Gets or sets the funds.
        /// </summary>
        public virtual ICollection<Fund> Funds { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether is information about funds.
        /// </summary>
        public virtual bool IsInformationAboutFunds { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether is information about progress.
        /// </summary>
        public virtual bool IsInformationAboutProgress { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether is information about results.
        /// </summary>
        public virtual bool IsInformationAboutResults { get; set; }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        public virtual string Name { get; set; }

        /// <summary>
        /// Gets or sets the owner projects.
        /// </summary>
        public virtual ICollection<Project> OwnerProjects { get; set; }

        /// <summary>
        /// Gets or sets the time of activity.
        /// </summary>
        public virtual DateTime? TimeOfActivity { get; set; }

        /// <summary>
        /// Gets or sets the type.
        /// </summary>
        public virtual NewsInformationType Type { get; set; }

        #endregion
    }

    /// <summary>
    /// The news information mapping.
    /// </summary>
    public class NewsInformationMapping : ClassMapping<NewsInformation>
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="NewsInformationMapping"/> class.
        /// </summary>
        public NewsInformationMapping()
        {
            this.Set(x => x.OwnerProjects, c => { }, m => m.ManyToMany());
            this.Property(x => x.Name);
            this.ManyToOne(x => x.Creator);
            this.Property(x => x.TimeOfActivity);
            this.Property(x => x.Comments, m => m.Length(int.MaxValue / 2));
            this.Property(x => x.ArchiveLocation);

            this.Property(x => x.IsInformationAboutFunds);
            this.Property(x => x.IsInformationAboutProgress);
            this.Property(x => x.IsInformationAboutResults);

            this.Set(x => x.Files, c => { }, m => m.ManyToMany());
            this.Set(x => x.Funds, c => { }, m => m.ManyToMany());
            this.ManyToOne(x => x.Type);
        }

        #endregion
    }
}